// Checkr
// ======
//
// Copyright Gilbert Pellegrom 2008
// This code is provided as is, bugs are probable, no responsibility accepted.
// http://www.gilbertpellegrom.co.uk

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Checkr
{
    public partial class Form2 : Form
    {
        private ProfileManager profMan;
        public Form1 frm1;

        public Form2()
        {
            InitializeComponent();
            profMan = new ProfileManager();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            bool error = false;
            if (textBox1.Text == "") error = true;
            if (textBox2.Text == "") error = true;
            if (textBox3.Text == "") error = true;
            if (textBox4.Text == "") error = true;
            if (comboBox1.Text == "") error = true;

            if (error)
            {
                return;
            }
            else
            {
                profMan.addProfile(comboBox1.Text, textBox2.Text, textBox3.Text, textBox1.Text, textBox4.Text, checkBox1.Checked);
                this.Close();
                ((Form1)frm1).listProfiles();
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void ssl_changed(object sender, EventArgs e)
        {
            if ((string)comboBox1.SelectedItem == "POP")
            {
                if (checkBox1.Checked)
                {
                    textBox4.Text = "995";
                }
                else
                {
                    textBox4.Text = "110";
                }
            }
            if ((string)comboBox1.SelectedItem == "IMAP")
            {
                if (checkBox1.Checked)
                {
                    textBox4.Text = "993";
                }
                else
                {
                    textBox4.Text = "143";
                }
            }
        }
    }
}